import numpy as np


def get_target_sitting_height(p, radius=0.05):
    """
    p: a posed chair/sofa/bed dense point cloud, dtype = np.float32, shape = (N, 3)
    """
    x_min, y_min = list(p.min(axis=0)[:2])
    x_max, y_max = list(p.max(axis=0)[:2])
    cx, cy = (x_min + x_max) * 0.5, (y_min + y_max) * 0.5
    valid = (p[:, 0] > cx - radius) & (p[:, 0] < cx + radius) & (p[:, 1] > cy - radius) & (p[:, 1] < cy + radius)
    p_around_center = p[valid]
    target_sitting_height = p_around_center[:, 2].max()
    return target_sitting_height